package leetcode;

import leetcode.entity.ListNode;

/**
 * @author:xufengxiang
 * @date 2023-04-11 19:49
 */
public class Code24 {

    public ListNode swapPairs(ListNode head) {
        if(head ==null || head.next == null){
            return head;
        }

        ListNode tmp = new ListNode();
        ListNode p = tmp;
        while(head!= null && head.next != null){
            p.next = head.next;
            head.next = head.next.next;
            p = p.next;
            p.next = head;

            head = head.next;
            p = p.next;
        }
        return tmp.next;
    }
}
